# -*- mijjcoding:utf-8 -*-
class Solution:
    def __init__(self):
        self.s = []
        self.min = []
        
    def push(self, node):
        # write code here
        self.s.append(node)
        if len(self.min) == 0:
            self.min.append(node)
        elif  self.min[-1] >= node:
            self.min.append(node)
            
    def pop(self):
        # write code here
        x = self.s.pop()
        if len(self.min)>0 and self.min[-1] == x:
            self.min.pop()
        return x
    def top(self):
        # write code here
        if len(self.s)>0:
            return self.s[-1]
        
    def min(self):
        # write code here
        if len(self.min)>0:
            return self.min[-1]
a = Solution()
x = a.push(1)
print x
x = a.top()
print x
x = a.min()
print x
x = a.pop()
print x
